package com.qf.dao.impl;

import com.qf.dao.CompanyDao;
import com.qf.entity.Company;
import com.qf.util.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/*
杨威
2021/9/25
14:22
*/
public class CompanyDaoImpl implements CompanyDao {
    QueryRunner queryRunner=new QueryRunner();
    @Override
    public List<Company> selectAll() {
        try {
            String sql="select * from company";
            List<Company> companyList = queryRunner.query(DruidUtil.getConnection(), sql, new BeanListHandler<>(Company.class));
            return companyList;
        } catch (SQLException e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}
